<% pie_total = chart_attrs[:legends].values.sum %>
<div id="<%= page_id %>container"></div>
	<script type="text/javascript">
		$(function () {
	    $('#<%= page_id %>container').highcharts({
	    	credits: false,
	        chart: {
	            plotBackgroundColor: null,
	            plotBorderWidth: null,
	            plotShadow: false
	        },
	        title: {
	            text: '<%= chart_attrs[:name] %>'
	        },
	        tooltip: {
            formatter: function () {
              return this.point.name + ' ' + this.point.y + '<%= chart_attrs[:uom] %>';
            }
	        },
	        plotOptions: {
	            pie: {
                allowPointSelect: true,
                cursor: 'pointer',
                dataLabels: {
                    enabled: true,
                    color: '#000000',
                    connectorColor: '#000000',
                    format: '<b>{point.name}</b>: {point.percentage:.1f} %'
                }
	            }
	        },
	        series: [{
	            type: 'pie',
	            name: '<%= chart_attrs[:labelname].to_s %>',
	            data: [
	            	<% chart_attrs[:legends].each do |label,value| %>
	            		['<%= label %>',<%= (100*value/pie_total).round(1) %>],
	            	<% end %>
	            ]
        }]
    });
	});
</script>
